package com.qyhl.module_home.home;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.gyf.immersionbar.ImmersionBar;
import com.qyhl.module_home.R;
import com.qyhl.module_home.R2;
import com.qyhl.webtv.basiclib.base.BaseActivity;
import com.qyhl.webtv.basiclib.base.BaseIViewPresenter;
import com.qyhl.webtv.commonlib.constant.ARouterPathConstant;

import butterknife.BindView;

/**
 * Created by qyhl on 2018/5/18.
 * 默认界面
 */
@Route(path = ARouterPathConstant.ACTIVITY_DEFAULT)
public class DefaultActivity extends BaseActivity {
    @BindView(R2.id.back_btn)
    ImageView backBtn;
    @BindView(R2.id.title)
    TextView mTitle;
    @Autowired(name = "title")
    String title;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);



    }

    @Override
    protected int getContentView() {
        return R.layout.home_activity_default;
    }

    @Override
    protected void setImmersionBar(ImmersionBar mImmersionBar) {
        setDefaultImmerBar();
    }

    @Override
    protected BaseIViewPresenter initBaseIViewPresenter() {
        return null;
    }

    @Override
    protected void init() {
        initView();
    }

    @Override
    protected void setListener() {

    }

    private void initView() {
        mTitle.setText(title);

        backBtn.setOnClickListener(v -> finish());

        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        TestFragment testFragment = new TestFragment();
        fragmentTransaction.add(R.id.fragment_container, testFragment);
        fragmentTransaction.commit();
    }
}
